package com.curso.sesion9;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

public class JavaBufferedReaderSystemInExample {

	public static void main (String[] args) throws Exception {
		String userName = null;

		//  prompt the user to enter their name
		System.out.print("Enter your name: ");

		//  open up standard input, and buffer it
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));

		// use the readLine method of the BufferedReader class
		// to get whatever line the user types in:
		userName = bufferedReader.readLine();
		System.out.println("Thanks for the name, " + userName);
		
		
		URL url = new URL("http://www.google.com");
		URLConnection urlConnection = url.openConnection();
		bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));

		String line;
		StringBuilder content = new StringBuilder();
		while ((line = bufferedReader.readLine()) != null) {
		  content.append(line + "\n");
		}
		bufferedReader.close();
		
		System.out.println(content);
	}
}